package com.jews.securityleam.starter.base;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.authority.AuthorityUtils;

/**
 * @author JewsChen
 * @title: LoginSuccessToken
 * @date 2023-06-19 0:44
 */
public class LoginSuccessToken extends AbstractAuthenticationToken {
    // 返回给前端的对象。可以加用户一些信息
    private final String token;

    private final String userName;

    public LoginSuccessToken(String token, String name) {
        super(AuthorityUtils.NO_AUTHORITIES);
        this.token = token;
        this.userName = name;
    }

    @Override
    public Object getCredentials() {
        return null;
    }

    @Override
    public Object getPrincipal() {
        return this.token;
    }

    public String getUserName() {
        return this.userName;
    }
}
